const { DataTypes } = require('sequelize');
const { nanoid } = require('nanoid');
const sequelize = require('../config/database');

const Customer = sequelize.define('Customer', {
  id: {
    type: DataTypes.STRING,
    primaryKey: true,
    defaultValue: () => nanoid()
  },
  name: {
    type: DataTypes.STRING,
    allowNull: false,
    comment: '客户姓名'
  },
  gender: {
    type: DataTypes.ENUM('男', '女'),
    allowNull: false,
    comment: '客户性别'
  },
  phone: {
    type: DataTypes.STRING,
    allowNull: false,
    unique: true,
    comment: '手机号'
  },
  birthDate: {
    type: DataTypes.DATEONLY,
    allowNull: true,
    comment: '出生年月'
  },
  remark: {
    type: DataTypes.TEXT,
    allowNull: true,
    comment: '备注'
  }
}, {
  timestamps: true,
  paranoid: true,
  tableName: 'customer'
});

module.exports = Customer;